// Maths header
// Maths library functions
// NOTE TO PROGRAMMERS: don't add code outside of regular C++ features
#ifndef MATHS_H
#define MATHS_H

#define LAZY template <typename T>


namespace Maths
{

	// Max
	LAZY
	T Max(T a, T b)
	{
		if (a > b) return a;
		return b;
	}

	// Min
	template <typename T>
	T Min(T a, T b)
	{
		if (a < b) return a;
		return b;
	}

	// Length
	template <typename T>
	float Length2D(T a, T b)
	{
		T vector = a - b;
		float length = sqrtf(vector.x * vector.x + vector.y * vector.y);
		return length;
	}

	template <typename T>
	float Length3D(T a, T b)
	{
		T vector = a - b;
		float length = sqrtf(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
		return length;
	}

	// Clamp
	template <typename T>
	T Clamp(T n, T min, T max)
	{
		if (n > max) return max;
		if (n < min) return min;
		return n;
	}

	// Saturate
	template <typename T>
	T Saturate(T n)
	{
		return Clamp<T>(n, 0, 1);
	}

	// Lerp
	template <typename T>
	T Lerp(T min, T max, float alpha)
	{
		return min + (max - min) * alpha;
	}
	
}

#include "SFML\Graphics.hpp"

void main2()
{

	float val = Maths::Lerp(2, 12, 0.5f);

	sf::Vector2f cat(0, 0);
	sf::Vector2f cheese(20, 10);

	float dist = Maths::Length2D(cat, cheese);

	cat = Maths::Lerp(cat, cheese, 0.5f);

	float f = Maths::Max<float>(5, 6);
	int i = Maths::Max(12, 20);
}



#endif // MATHS_H